<!DOCTYPE html>
<html>
    <head>
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'employee.label', default: 'Employee')}" />
        <title>员工：${this.employee.fullName}</title>
    </head>
    <body class="fixed-navbar fixed-sidebar">
        <div class="small-header">
            <div class="hpanel">
                <div class="panel-body">
                    <div id="hbreadcrumb" class="pull-right">
                        <ol class="hbreadcrumb breadcrumb">
                            <li>Next CRM</li>
                            <li><g:link controller="employee" action="index">员工管理</g:link></li>
                            <li class="active">
                                <span>${this.employee.fullName}</span>
                            </li>
                        </ol>
                    </div>

                    <h2 class="font-light m-b-xs" style="text-transform:none;">
                        查看员工信息
                    </h2>
                </div>
            </div>
        </div>
        <div class="content animate-panel">
            <div class="hpanel hblue row">
                <div class="panel-heading">
                    <div class="panel-tools">
                      <sec:ifNotGranted roles="ROLE_COO">
                        <g:link class="btn btn-info btn-xs" action="edit" resource="${this.employee}" id="${this?.employee?.id}"><i class="fa fa-edit"></i>编辑</g:link>
                      </sec:ifNotGranted>
                    </div>
                    主要信息
                </div>

                <div class="panel-body">
                    <div class="row">
                        <div class="col-md-2 border-right">
                            <div class="contact-stat">
                                <span>姓名</span>
                                <strong>${this.employee?.fullName}</strong>
                            </div>
                        </div>
                        <div class="col-md-2 border-right">
                            <div class="contact-stat">
                                <span>性别</span>
                                <strong>${this.employee?.gender}</strong>
                            </div>
                        </div>
                        <div class="col-md-2 border-right">
                            <div class="contact-stat">
                                <span>手机</span>
                                <strong>${this.employee?.cellphone}</strong>
                            </div>
                        </div>
                        <div class="col-md-2 border-right">
                            <div class="contact-stat">
                                <span>生日</span>
                                <strong>${this.employee?.birthday}</strong>
                            </div>
                        </div>
                        <div class="col-md-2 border-right">
                            <div class="contact-stat">
                                <span>身份证</span>
                                <strong>${this.employee?.idNumber}</strong>
                            </div>
                        </div>
                        <div class="col-md-2 border-right">
                            <div class="contact-stat">
                                <span>上级</span>
                                <strong>${this.employee?.manager?.fullName}</strong>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="hpanel hyellow">
                    <div class="panel-heading">
                        <div class="panel-tools">
                          <sec:ifNotGranted roles="ROLE_COO">
                            <g:link class="btn btn-xs btn-info" controller="employeePosition" action="create" params="[employee: this.employee?.id]"><i class="fa fa-plus"></i>新增</g:link>
                          </sec:ifNotGranted>
                            <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                        </div>
                        岗位
                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="department" title="部门"/>
                                    <g:sortableColumn property="position" title="岗位"/>
                                    <g:sortableColumn property="startTime" title="开始时间"/>
                                    <g:sortableColumn property="endTime" title="截止时间"/>
                                    <g:sortableColumn property="active" title="有效"/>
                                    <g:sortableColumn property="isPrimary" title="主要"/>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${com.next.EmployeePosition.findAllByEmployee(this.employee)}">
                                    <div class="col-md-4">
                                        <tr>
                                            <td><g:link action="show" controller="employee" id="${it?.id}" class="firstTd">${it?.position?.department?.name}</g:link></td>
                                            <td>${it?.position?.name}</td>
                                            <td>${it?.startTime}</td>
                                            <td>${it?.endTime}</td>
                                            <td>${it?.active}</td>
                                            <td>${it?.isPrimary}</td>
                                        </tr>
                                    </div>
                                </g:each>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="hpanel hgreen">
                    <div class="panel-heading">
                        <div class="panel-tools">
                          <sec:ifNotGranted roles="ROLE_COO">
                            <g:link class="btn btn-xs btn-info" controller="employee" action="create" id="${this.employee.id}"><i class="fa fa-plus"></i>新增</g:link>
                          </sec:ifNotGranted>
                            <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                        </div>
                        下属
                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="fullName" title="姓名"/>
                                    <g:sortableColumn property="department" title="部门"/>
                                    <g:sortableColumn property="posation" title="岗位"/>
                                    <g:sortableColumn property="startTime" title="开始时间"/>
                                    <g:sortableColumn property="endTime" title="截止时间"/>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${com.next.Employee.findAllByManager(this.employee)}">
                                    <div class="col-md-4">
                                        <tr>
                                            <td><g:link action="show" controller="employee" id="${it?.id}" class="firstTd">${it?.fullName}</g:link></td>
                                            <td>${com.next.EmployeePosition.findByEmployeeAndIsPrimary(it, true)?.position?.name}</td>
                                            <td>${com.next.EmployeePosition.findByEmployeeAndIsPrimary(it, true)?.position?.department?.name}</td>
                                            <td>${com.next.EmployeePosition.findByEmployeeAndIsPrimary(it, true)?.startTime}</td>
                                            <td>${com.next.EmployeePosition.findByEmployeeAndIsPrimary(it, true)?.endTime}</td>
                                        </tr>
                                    </div>
                                </g:each>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>
